import axios from 'axios';


let host = '/api/api';
// let host = 'http://127.0.0.1:8000/api';
// let host = 'https://www.yegang.shop';

//获取导航栏
export const getLevel = params => {
    return axios.get(`${host}/level`, {
        params: params
    })
}

export const getFirstLevel = params => {
    return axios.get(`${host}/firstlevel`, {
        params: params
    })
}


//查询单个一级标题
export const showFirstLevel = params => {
    return axios.get(`${host}/firstlevel/${params}/`)
}

//添加一级标题
export const addFirstLevel = params => {
    return axios.post(`${host}/firstlevel/`, params)
}

//更新一级标题
export const updateFirstLevel = params => {
    return axios.put(`${host}/firstlevel/${params.id}/`, params)
}

//删除一级标题
export const RemoveFirstLevel = id => {
    return axios.delete(`${host}/firstlevel/${id}/`)
}

//获取二级标题
export const getSecondLevel = params => {
    return axios.get(`${host}/secondlevel/`, {
        params: params
    })
}

//添加二级标题
export const addSecondLevel = params => {
    return axios.post(`${host}/secondlevel/`, params)
}
//查找单个二级标题
export const showSecondLevel = params => {
    return axios.get(`${host}/secondlevel/${params}/`)
}

//更新二级标题
export const updateSecondLevel = params => {
    return axios.put(`${host}/secondlevel/${params.id}/`, params)
}

//删除二级标题
export const RemoveSecondLevel = id => {
    return axios.delete(`${host}/secondlevel/${id}/`)
}

//用户登录
export const login = params => {
    return axios.post(`${host}/login/`, params)
}

//更改密码
export const ChangePassword = params => {
    return axios.post(`${host}/changePassword/`, params)
}
//退出登录
export const Logout = params => {
    return axios.get(`${host}/logout/`, {
        params: params
    })
}


//获取餐补余额
export const getMealSupplementBalance = params => {
    return axios.get(`${host}/MealSupplementBalance/`, {
        params: params
    })
}

//更新餐补余额
export const updateMealSupplementBalance = params => {
    return axios.put(`${host}/MealSupplementBalance/${params.id}/`, params)
}

//查询订单
export const getOrder = params => {
    return axios.get(`${host}/order/`, {
        params: params
    })
}

//添加订单
export const addOrder = params => {
    return axios.post(`${host}/order/`, params)
}
//查询用户
export const getUser = params => {
    return axios.get(`${host}/user/`, {
        params: params
    })
}

//添加用户
export const addUser = params => {
    return axios.post(`${host}/user/`, params)
}

//查找单个用户
export const showUser = params => {
    return axios.get(`${host}/user/${params}/`)
}

//更新用户
export const updateUser = params => {
    return axios.put(`${host}/user/${params.id}/`, params)
}

//删除用户
export const RemoveUser = id => {
    return axios.delete(`${host}/user/${id}/`)
}

//查询用户组
export const getGroup = params => {
    return axios.get(`${host}/group/`, {
        params: params
    })
}

//添加用户组
export const addGroup = params => {
    return axios.post(`${host}/group/`, params)
}

//查找单个用户组
export const showGroup = params => {
    return axios.get(`${host}/group/${params}/`)
}

//更新用户组
export const updateGroup = params => {
    return axios.put(`${host}/group/${params.id}/`, params)
}

//删除用户组
export const RemoveGroup = id => {
    return axios.delete(`${host}/group/${id}/`)
}

